<?php
session_start();
require_once("common/config.php");
$conn = new connectDb();

$user_id = getUserId($_SESSION['login_mail']);

destroyCookie($user_id);

//销毁cookie
function destroyCookie($user_id)
{
	//将用户数据更改为历史数据
	//mysql_query("UPDATE `food_user_data` SET `history_data` = 1 WHERE `history_data` = 0 AND `user_id` = '".$user_id."'");
	
	unset($_SESSION['login_mail']);
	
	unset($_SESSION['qq_photoUrl']);
	
	unset($_SESSION['qq_nickname']);
	
	unset($_SESSION['user_prepassword']);
	
	echo "<script language=\"javascript\">location.href='login.php';</script>";
}

//将邮件转换为user_id
function getUserId($login_mail)
{
	$query = mysql_query("SELECT `id` FROM `food_user_basic` WHERE `user_mail` = '".$login_mail."'") or die (mysql_error());
	$row = mysql_fetch_array($query);
	$user_id = $row['id'];
	
	return $user_id;
}
?>